<?php $path = Yii::app()->request->baseUrl . '/'; ?>

<div style="clear:both;">
    <div style="position: relative;float:left;width: 50%;">
        <h2><font style="color: #0066A4;">MANAGE CATEGORY</font></h2>
    </div>
    <div style="position: relative;float:right;width: 25%;padding-top: 10px;">
        <link href="<?php echo $path ?>css/search.css" rel="stylesheet" type="text/css" />
        <a id="show_hide" href="javascript:void(0)" onclick="jQuery('#_section').toggle();">
            <?php echo CHtml::image($path . 'css/img/search.png', 'Search', array('width' => 23, 'height' => 20)); ?>
        </a>
        <div id ="_section" style="display:none; padding:5px 10px 0; background-color:#EEE; z-index: 1; position:absolute; border:#AFD0F5 1px; border-style:ridge;">
            <style type="text/css">
                div.form .row {
                    margin: 5px 0;
                    margin-bottom: 0px;
                }
            </style>
            <div class="form">
                <?php
                $form = $this->beginWidget('CActiveForm', array(
                    'id' => 'search-form',
                    'action' => array('search'),
                    'enableAjaxValidation' => true,
                    'htmlOptions' => array('accept-charset' => 'UTF-8'),
                ));
                ?>
                <?php echo $form->errorSummary($categorySearch); ?>
                <div>
                    <?php echo $form->textField($categorySearch, 'keyWord', array('size' => 30, 'maxlength' => 100, 'placeholder' => 'Press key to search')); ?>
                    <?php echo $form->error($categorySearch, 'keyWord'); ?>
                </div>

                <div class="row buttons">
                    <?php echo CHtml::submitButton(Yii::t('post', 'Search'), array('width' => 20)); ?>
                </div>

                <?php $this->endWidget(); ?>

            </div>   
        </div>
    </div>
</div>
<div style="clear:both;">
    <?php if (Yii::app()->user->hasFlash('success')): ?>
        <div class="flash-notice">
            <?php echo Yii::app()->user->getFlash('success'); ?>
        </div>
    <?php endif; ?>
    <?php
    $this->widget('zii.widgets.grid.CGridView', array(
        'id' => 'category-grid',
        'dataProvider' => $dataProvider,
        //'filter' => $category,
        'ajaxUpdate' => true,
        'pager' => array(
            //'cssFile'=>false,
            'class' => 'CLinkPager',
            'header' => '',
            'maxButtonCount' => 10,
            'pageSize' => 15,
            'firstPageLabel' => '<<',
            'prevPageLabel' => 'Prev',
            'nextPageLabel' => 'Next',
            'lastPageLabel' => '>>',
        ),
        'columns' => array(
            array(
                'name' => 'ID',
                'value' => '$data->id',
            ),
            array(
                'name' => 'Parent Category',
                'value' => '$data->getCategoryNameById($data->parent_id)',
            ),
            array(
                'name' => 'Is Displayed',
                'value' => '$data->is_displayed',
            ),
            array(
                'name' => 'Name',
                'value' => '$data->getCategoryDetail("en")->name',
            ),
            array(
                'name' => 'Seokey',
                'value' => '$data->getCategoryDetail("en")->seokey',
            ),
            array(
                'name' => 'Created At',
                'value' => '$data->created_at',
            ),
            array(
                'name' => 'Updated At',
                'value' => '$data->updated_at',
            ),
            array(
                'class' => 'CButtonColumn',
                'template' => '{update}{delete}'
            ),
        ),
    ));
    ?>
</div>